﻿using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace iot.Jobs
{
    class QueueMessageBus
    {
        private readonly BlockingCollection<int> _queue = new BlockingCollection<int>();
        public QueueMessageBus()
        {

        }
        public void Publish(int message)
        {
            _queue.Add(message);
        }

        public IEnumerable<int> Subscribe()
        {
            return _queue.GetConsumingEnumerable();
        }

        public void Complete()
        {
            _queue.CompleteAdding();
        }
    }
}
